﻿using System;

namespace HslCommunication.Core.IMessage
{
	/// <summary>
	/// 三菱的A兼容1E帧协议解析规则
	/// </summary>
	// Token: 0x0200015D RID: 349
	public class MelsecA1EBinaryMessage : INetMessage
	{
		/// <inheritdoc cref="P:HslCommunication.Core.IMessage.INetMessage.ProtocolHeadBytesLength" />
		// Token: 0x170005F3 RID: 1523
		// (get) Token: 0x06001D78 RID: 7544 RVA: 0x0008D732 File Offset: 0x0008B932
		public int ProtocolHeadBytesLength
		{
			get
			{
				return 2;
			}
		}

		/// <inheritdoc cref="M:HslCommunication.Core.IMessage.INetMessage.GetContentLengthByHeadBytes" />
		// Token: 0x06001D79 RID: 7545 RVA: 0x0008D738 File Offset: 0x0008B938
		public int GetContentLengthByHeadBytes()
		{
			bool flag = this.HeadBytes[1] == 91;
			int result;
			if (flag)
			{
				result = 2;
			}
			else
			{
				bool flag2 = this.HeadBytes[1] == 0;
				if (flag2)
				{
					switch (this.HeadBytes[0])
					{
					case 128:
						result = (int)((this.SendBytes[10] != 0) ? ((this.SendBytes[10] + 1) / 2) : 128);
						break;
					case 129:
						result = (int)(this.SendBytes[10] * 2);
						break;
					case 130:
					case 131:
						result = 0;
						break;
					default:
						result = 0;
						break;
					}
				}
				else
				{
					result = 0;
				}
			}
			return result;
		}

		/// <inheritdoc cref="M:HslCommunication.Core.IMessage.INetMessage.CheckHeadBytesLegal(System.Byte[])" />
		// Token: 0x06001D7A RID: 7546 RVA: 0x0008D7D4 File Offset: 0x0008B9D4
		public bool CheckHeadBytesLegal(byte[] token)
		{
			bool flag = this.HeadBytes != null;
			return flag && this.HeadBytes[0] - this.SendBytes[0] == 128;
		}

		/// <inheritdoc cref="M:HslCommunication.Core.IMessage.INetMessage.GetHeadBytesIdentity" />
		// Token: 0x06001D7B RID: 7547 RVA: 0x00047BE1 File Offset: 0x00045DE1
		public int GetHeadBytesIdentity()
		{
			return 0;
		}

		/// <inheritdoc cref="P:HslCommunication.Core.IMessage.INetMessage.HeadBytes" />
		// Token: 0x170005F4 RID: 1524
		// (get) Token: 0x06001D7C RID: 7548 RVA: 0x0008D80F File Offset: 0x0008BA0F
		// (set) Token: 0x06001D7D RID: 7549 RVA: 0x0008D817 File Offset: 0x0008BA17
		public byte[] HeadBytes { get; set; }

		/// <inheritdoc cref="P:HslCommunication.Core.IMessage.INetMessage.ContentBytes" />
		// Token: 0x170005F5 RID: 1525
		// (get) Token: 0x06001D7E RID: 7550 RVA: 0x0008D820 File Offset: 0x0008BA20
		// (set) Token: 0x06001D7F RID: 7551 RVA: 0x0008D828 File Offset: 0x0008BA28
		public byte[] ContentBytes { get; set; }

		/// <inheritdoc cref="P:HslCommunication.Core.IMessage.INetMessage.SendBytes" />
		// Token: 0x170005F6 RID: 1526
		// (get) Token: 0x06001D80 RID: 7552 RVA: 0x0008D831 File Offset: 0x0008BA31
		// (set) Token: 0x06001D81 RID: 7553 RVA: 0x0008D839 File Offset: 0x0008BA39
		public byte[] SendBytes { get; set; }
	}
}
